n=49**7+7**21-7
k=0
while n>0:
    if n%7==6:
            k=k+1
    n=n //7
print (k)
    

